package com.day11.test6_jdk8_date;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * @author 小坡
 * @date 2022/9/14  16:56
 **/
public class TestDate {
    public static void main(String[] args) {
//public static Durationbetween(开始时间,结束时间)计算两个“时间"的间隔
        LocalDateTime localDateTime1 = LocalDateTime.of(2022, 9, 14, 16, 14, 1);
        LocalDateTime localDateTime2 = LocalDateTime.of(2099, 12, 15, 17, 23, 25);
        Duration between = Duration.between(localDateTime1, localDateTime2);
        System.out.println(between);  //PT677185H9M24S  677185小时 9分钟  24秒


// public long toMinutes()获得此时间间隔的分钟
        System.out.println(between.toMinutes());
//      public int EoMillis()获得此时间间隔的毫秒
        System.out.println(between.toMillis());
//        public int toNanos ( )获得此时间间隔的纳秒
        System.out.println(between.toNanos());
    }
}
